home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Belgian Amiga Club - ADF Collection
/
BS1 part 47.7z
/
BS1 part 47
/
ImageMaster RT v1.50b (1994)(Black Belt Systems)(Disk 6 of 7)[HD].7z
/
ImageMaster RT v1.50b (1994)(Black Belt Systems)(Disk 6 of 7)[HD].adf
/
piarc.lzh.parta
/
MetaScanIM.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1994-03-17
|
8KB
|
353 lines
/*
$Id: MetaScanIM.rexx,v 1.4 1993/01/16 00:04:13 Vic Exp $
$Log: MetaScanIM.rexx,v $
* Revision 1.4 1993/01/16 00:04:13 Vic
* Added - an 'options failat...' to keep the script from complaining if
* it's terminated by closing MetaScanIM
* - a port of our own ('MetaScanRexxing') so we can make sure we
* don't accidently get re-executed. If we ARE re-executed, we
* simply bring MetaScanIM 'tofront' and exit gracefully
* - an OPTIONS RESULTS at the beginning of the loop (I'm not sure
* how it gets left at the end of the loop).
* - some calls to 'closeport' to close our port
* Changed - the location of where we initialize MetaScanPort
* Delete - the automatic "Preview" when MetaScanIM is 1st loaded
*
* Revision 1.3 1993/01/15 22:50:14 Vic
* Added - an ADDRESS(MetaScanPort) in the 'do forever' loop so WE get
* the 'getscan' command instead of Imagemaster
*
* Revision 1.2 1993/01/14 21:59:30 Vic
* Changed - some spellings to add the 'IM' to the end of some 'MetaScan's
*
* Revision 1.1 1993/01/13 21:49:32 Vic
* Initial revision
*
Revision 1.3 92/04/13 15:02:58 Vic
Added - stuff to let us supply unique name for scanned buffers
Changed - 'newbuf' to 'newasprimary' so the added code works
Revision 1.2 92/01/10 02:19:44 Ken
Changed - The loading of metascan to look in the current directory
or the current path and not just c:.
Changed the name of scanner to metascan.
Revision 1.1 91/12/30 23:04:41 Ken
Initial revision
*
* MetaScan.rexx
*
* Written by: Kenneth T. Spoor
* Last Update: 21 Dec 1991
* Revision: 1.1
* For: Black Belt Systems image processing series IM, IM F/c, and IP.
*
* Note: This script is created by modifying one of Black Belt Systems
* existing scripts. Thanks Ben!
*/
options failat 600
call pragma('stack',20000);
/*
* open rexxsupport.library -- needed for some functions
*/
IF ~SHOW('L',"rexxsupport.library") THEN
DO
IF ADDLIB('rexxsupport.library',0,-30,0) THEN
DO
/* everything's ok */
END;
ELSE
DO
SAY 'We Have A Library Problem, Unable To Load "rexxsupport.library"';
SAY 'Cannot operate MetaScanIM.rexx without this library - sorry!';
EXIT(10);
END;
END;
/*
* If the script is running already, just 'push' the MetaScanIM screen
* to the front. To the user, it should be indistinguishable from just
* starting the script.
*/
MetaScanPort = 'METASCAN';
IF SHOW('P','MetaScanRexxing') THEN
DO
ADDRESS(MetaScanPort);
ToFront; /* Bring MetaScan Screen forward */
ToFront; /* Bring MetaScan Screen forward */
EXIT(0);
END;
call openport('MetaScanRexxing');
/*
* This will automatically direct the script to the proper
* software, If it is running. No matter where the script is
* launched from. :^) I sure do like ARexx. :^))
*/
IM_PortName = 'IM_Port'; /* assume Image Professional */
IF SHOW('P',IM_PortName) = 0 THEN
DO
SAY "Can't find Imagemaster's ARexx port!!!"; /* not running? */
SAY "This script requires Imagemaster to run!";
call closeport('MetaScanRexxing');
EXIT(20);
END;
/*
* We Only Load From The Scanner
*/
ADDRESS(IM_PortName);
OPTIONS RESULTS;
/*
* PI driver for MetaScanIM
*/
OpenedMetaScan = 0;
IF SHOW('P', MetaScanPort) = 0 THEN
DO
ADDRESS COMMAND 'run cmpi:MetaScanIM behind';
count = 0;
ADDRESS COMMAND WaitForPort MetaScanPort;
IF RC ~= 0 THEN
DO
SAY "Can't find MetaScanIM!!!";
SAY "This script requires MetaScanIM to be running or";
SAY " the program to be in the CMPI: assignment!";
CALL DoExit(30);
END;
ADDRESS(MetaScanPort);
OPTIONS RESULTS;
count = 0;
DO WHILE count < 20
ScannerReady;
IF RESULT = "READY" THEN BREAK
ELSE ADDRESS COMMAND "wait 1";
count = count + 1;
END;
ScannerReady;
IF RESULT ~= "READY" THEN
DO
SAY "Error - MetaScanIM didn't become ready!!!";
CALL DoExit(40);
END
OpenedMetaScan = 1;
END
/*
* At this point, we have at least some assurance that we
* have 'MetaScanIM' running. Now, we need to let the user
* select the image they wants, so we can open a new
* buffer of the appropriate size.
*/
ADDRESS(MetaScanPort);
ToFront; /* Bring MetaScan Screen forward */
ToFront; /* Bring MetaScan Screen forward */
OPTIONS RESULTS;
'SetViewMode None';
DO FOREVER
OPTIONS RESULTS;
ADDRESS(MetaScanPort);
GetScan;
IF RC ~= 0 THEN
DO
ADDRESS COMMAND "wait 1";
CALL DoExit(50);
END;
Current; /* get the image imformation */
Settings = RESULT;
OPTIONS;
PARSE VAR Settings ScanMode Measure Start_X Start_Y Width Height
/*
XDPI
YDPI
XZoom
YZoom
Planes
DropoutColor
Halftoning
GammaCorrection
ColorCorrection
Brightness
Keep
*/
ADDRESS(IM_PortName);
'imtofront'; /* show user the IM screen */
/* is there already a primary buffer??? */
OPTIONS RESULTS;
'current';
bufdata = RESULT;
OPTIONS;
PARSE VAR bufdata bname ',' bnum ',' bx ',' by ',' btot ',' bmem ',' bparname ',' bparnum
IF bname ~= '<none>' THEN
DO
ADDRESS(IM_PortName);
OPTIONS RESULTS;
'askyn '||'"Replace Primary ['||bname||']" "New As Primary"'
prefs = RESULT;
OPTIONS;
ADDRESS;
IF prefs = 0 THEN
DO
ADDRESS(IM_PortName);
'killbuff '||bnum; /* this kills the Primary Buffer */
ADDRESS;
END;
END;
ADDRESS(MetaScanPort);
ToFront; /* Bring MetaScan Screen forward */
ToFront; /* Bring MetaScan Screen forward */
/* New buffer is created at current resolution */
ADDRESS(IM_PortName);
'autoredraw 0';
'newasprimary '||Width||' '||Height;
OPTIONS RESULTS;
'current';
bufdata = RESULT;
OPTIONS;
PARSE VAR bufdata bname ',' bnum ',' bx ',' by ',' btot ',' bmem ',' bparname ',' bparnum
OPTIONS RESULTS;
'buffers';
s = RESULT;
idx = 0;
f = "MetaScan";
do i = 1 while length(subword(s,i,1)) > 0
p = subword(s,i, 1) /* isolate the current suspect */
if (pos(upper(f), upper(p))) ~= 1 then iterate /* something irrelevant? */
if pos(",", p) = 0 then iterate /* ignore things I dont understant */
p = substr(p, length(f)+1) /* get the stuff behind our name */
if (p = ',') then
idxt = 1 /* nothing behind so nominate 1 */
else
idxt = substr(p,1,length(p)-1)+1 /* nominate one past this one */
if idx < idxt then /* will our nomination pass?? */
idx = idxt
end
if idx == 0 then
do
'rename '||bnum||' MetaScan';
end
else
do
'rename '||bnum||' MetaScan'||idx;
end
'autoredraw 1';
ADDRESS(IM_PortName);
OPTIONS RESULTS;
jackin;
jackadr = RESULT;
ADDRESS(MetaScanPort);
OPTIONS RESULTS;
Status = 0;
IMGetImage jackadr; /* copy the scan to IM */
IF RC ~= 0 THEN Status = 60;
CALL DoExit(Status);
END;
DoExit:
ARG RetCode;
ADDRESS(IM_PortName);
'imtofront';
IF SHOW('P', MetaScanPort) ~= 0 THEN
DO
IF OpenedMetaScan = 1 THEN
DO
OPTIONS RESULTS;
'askyn '||'"Keep MetaScanIM Loaded" "Remove MetaScanIM"'
prefs = RESULT;
OPTIONS;
IF prefs ~= 0 THEN
DO
ADDRESS(MetaScanPort);
Quit; /* get rid of MetaScanIM */
ADDRESS;
OPTIONS;
call closeport('MetaScanRexxing');
EXIT(RetCode);
END;
END;
END;
IF RetCode = 0 THEN
DO
'redraw';
RETURN;
END;
call closeport('MetaScanRexxing');
EXIT(RetCode);